package com.javafactroy.kunlong.framework.ruleengine;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;


public class DroolsService {
    public static void fire(Object... facts){
        KieServices kieServices = KieServices.Factory.get();
        // 获取 kieContainer
        KieContainer kieContainer = kieServices.newKieClasspathContainer();
        // 获取 kieSession
        KieSession kieSession = kieContainer.newKieSession();
        for(Object fact:facts){
         kieSession.insert(fact);
        }
        // 激活规则,由drools自行匹配, 匹配成功则执行规则
        kieSession.fireAllRules();
        // 关闭session
        kieSession.dispose();

    }
}
